<?php 

function option($items, $parent_id, $cat_id, $level=0) {
    foreach ($items as $item) {
        if ($item['id']==$cat_id) continue;
        
        $selected = ($item['id']==$parent_id) ? 'selected' : '';
        echo '<option value="'.$item['id'].'" '.$selected.'>';
        echo str_repeat('├─', $level).$item['name'];
        if (isset($item['children']) && is_array($item['children'])) {
            option($item['children'], $parent_id, $cat_id, $level+1);
        }
        echo '</option>';
    }
}
?>
<style>
.max-line1 {
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;	
}
.max-line2 {
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
</style>
<style>
.media-body .summary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
	text-overflow: ellipsis;
    overflow: hidden;
}
.media-list img {width: 200px;}
@media (max-width: 425px)  {
    .media-list img {width: 115px;}	
    .media-body .summary {display: none;}
}
</style>

<h3 class="page-header">项目列表 
<a href="<?= URL::site('project/add');?>" class="ajax-click">+</a>
</h3>

<form class="form-inline ajax-submit" method="get">

    <div class="form-group">
        <select class="form-control" name="status">
			<option value="">选择状态</option>
			<option value="1" <?php if(Arr::get($_GET, 'status')=='1'):?>selected<?php endif;?>>进行中</option>
			<option value="2" <?php if(Arr::get($_GET, 'status')=='2'):?>selected<?php endif;?>>已终止</option>
			<option value="3" <?php if(Arr::get($_GET, 'status')=='3'):?>selected<?php endif;?>>已完成</option>
        
        </select>
    </div>
    <div class="form-group">
        <select class="form-control" name="project_cid">
			<option value="">选择项目分类</option>
			<?php foreach($projectCategory as $item): ?>
			<option value="<?php echo $item['id']?>" <?php if(Arr::get($_GET, 'project_cid')==$item['id']):?>selected<?php endif;?>><?php echo $item['name']?></option>
    		<?php endforeach; ?>	
        </select>
    </div>
    <div class="form-group">
        <select class="form-control" name="profession_cid">
			<option value="">选择行业分类</option>
			<?php foreach($professionCategory as $item): ?>
			<option value="<?php echo $item['id']?>" <?php if(Arr::get($_GET, 'profession_cid')==$item['id']):?>selected<?php endif;?>><?php echo $item['name']?></option>
    		<?php endforeach; ?>	
        </select>
    </div>
    
    <div class="form-group">
        <div class="input-group">
            <input type="text" class="form-control" name="project_name" value="<?php echo Arr::get($_GET, 'project_name')?>" placeholder="">
            <span class="input-group-btn">
                <button class="btn btn-info" type="submit">查找</button>
            </span>
        </div>
     </div>
</form>
<br>

<ul class="media-list">
<?php foreach($list as $item): ?>
    <li class="media">
        <div class="media-left">
            <?php if (strpos($item['pic'], '://') !== false):?>
            <?= HTML::image($item['pic'].'?imageView2/2/w/160/h/120') ?>
            <?php else:?>
            <?= HTML::image('/imagefly/w160-h120-c/' . $item['pic']) ?>
            <?php endif;?>
        </div>
        
        <div class="media-body">
            <h4 class="media-heading">项目名称:<?= $item['project_name'] ?></h4>
            <p class="text-muted summary">类型:<?= $item['project_cid']?></p>
            <p class="text-muted summary">导演:<?= $item['director'] ?></p>
            
            
          	
            
            <?php if ($item['is_recommend']==1):?>
            <a href="<?= URL::site('project/close2?id='.$item['id']);?>" class="btn btn-danger btn-xs ajax-update">不推荐</a>
            <?php else:?>
            <a href="<?= URL::site('project/open2?id='.$item['id']);?>" class="btn btn-info btn-xs ajax-update">推荐</a>
            <?php endif;?>
            
    	    <a href="<?= URL::site('project/edit')?>?id=<?= $item['id'] ?>" class="btn btn-info btn-xs ajax-click">修改</a>
    	    
    	    <a href="<?= URL::site('project/addmember')?>?id=<?= $item['id'] ?>" class="btn btn-info btn-xs ajax-click">添加成员</a>
    	    
    	    <a href="<?= URL::site('project/adddevice')?>?id=<?= $item['id'] ?>" class="btn btn-info btn-xs ajax-click">添加设备</a>
    	    
    	    <a href="<?= URL::site('project/addplace')?>?id=<?= $item['id'] ?>" class="btn btn-info btn-xs ajax-click">添加场地</a>
    	    
       	</div>
    </li>
<?php endforeach; ?>
</ul>

<?= $pager ?>
